package collection;

import java.util.*;

/**
 * Collections.sort
 */
public class SortInteger {
    public static void main(String[] args) {
        Random rand = new Random();
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<10;i++){
            list.add(rand.nextInt(100));
        }
        System.out.println("list的数据:"+list);

        //自然排序
        Collections.sort(list);//从小打大
        System.out.println("list:"+list);

        Collections.reverse(list);//反转 数据已经变了 for循环输出可见变化
        System.out.println("list:"+list);//从大到小
        for (Integer str : list){
            System.out.println(str);
        }

        Integer a1 = list.get(0);
        System.out.println("第一个元素:"+a1);
    }
}
